import request from "@/utils/request";

//工单相关api
const workApi = {
	// 提交工单
	create(data : CreateParams) {
		return request.post<dataResult>({ url: "/api/customer/ticket/create", data });
	},
	// 工单列表
	getlist(data : ListParams) {
		return request.post<dataResult>({ url: "/api/customer/ticket/getlist", data });
	},
	// 工单详情
	getdetail(data : DetailParams) {
		return request.post<dataResult>({ url: "/api/customer/ticket/getdetail", data });
	},
	// 回复工单
	reply(data : ReplyParams) {
		return request.post<dataResult>({ url: "/api/customer/ticket/reply", data });
	},
	// 完结工单
	changestatus(data : ChangestatusParams) {
		return request.post<dataResult>({ url: "/api/customer/ticket/changestatus", data });
	}
};

export default workApi;

interface dataResult {
	data ?: any;
	message : string;
	status : number;
}

//提交工单
interface CreateParams {
	type : string;
	order_no ?: string;
	title : string;
	content ?: string;
	image ?: string[];
}

// 工单列表请求参数
interface ListParams {
	page : number;
	limit : number;
	order_no : string;
	status : number;
}

// 工单详情
interface DetailParams {
	id : number;
}

// 工单详情
interface ReplyParams {
	id : number;
	content : string;
	image : string;
}

// 工单详情
interface ChangestatusParams {
	id : number;
	status : number;
}